package helloworld.admin.action.course;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import helloworld.admin.assembler.course.CourseFormAssembler;
import helloworld.admin.bean.CourseAdminBean;
import helloworld.admin.form.course.CourseForm;
import helloworld.delegate.course.CourseDelegate;
import org.apache.struts.actions.DispatchAction;

public class CourseShowAction extends DispatchAction {
	
	public ActionForward Create(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		return mapping.findForward("courseFormPage");
	}
	
	public ActionForward Edit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		CourseDelegate delegate = new CourseDelegate();
		CourseAdminBean course = delegate.getCourseDetail(request.getParameter("courseName"));
		CourseForm custForm = CourseFormAssembler.createCourseForm(course);
		request.setAttribute("CourseForm", custForm);
		return mapping.findForward("courseFormPage");
	}
}
